<?php


namespace app\adminapi\lists\member;


use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\lists\ListsSortInterface;
use app\common\model\member\MemberBenefit;
use app\common\model\member\MemberLevel;

/**
 * @projectName src
 */
class MemberBenefitLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface
{

    /**
     * 设置搜索条件
     */
    public function setSearch(): array
    {
        return [
            '%like%'=>['benefit_name','use_caluse','use_dept'],
            '='=>['id']
        ];
    }

    /**
     * 设置支持排序字段
     */
    public function setSortFields(): array
    {
        return ['create_time' => 'create_time', 'id' => 'id'];
    }

    /**
     * 设置默认排序
     */
    public function setDefaultOrder(): array
    {
        return ['id' => 'desc'];
    }

    /**
     * 获取列表
     * @return array
     */
    public function lists(): array
    {
        $memberBenefitLists = MemberBenefit::where($this->searchWhere)
            ->limit($this->limitOffset, $this->limitLength)
            ->order($this->sortOrder)
            ->select()
            ->toArray();
        return $memberBenefitLists;
    }

    /**
     * 获取数量
     */
    public function count(): int
    {
        return MemberBenefit::where($this->searchWhere)->count();
    }

    public function extend()
    {
        return [];
    }
}